<template>
  <div id="app">
    <span @click="aboutusBtn">关于我们-编程式导航</span>
    <span @click="hotnewsBtn">最热新闻-编程式导航</span>
    <div class="com">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  name: "App",
  components: {},
  methods: {
    aboutusBtn() {
      console.log(this);
      // $router:vueRouter的实例化对象-关于路由对象的方法
      this.$router.push({
        path: "/aboutus",
      });
    },
    hotnewsBtn() {
      this.$router.push({
        path: "/hotnews",
      });
    },
  },
  mounted() {
    console.log(this.$router);
  },
};
</script>

<style>
a {
  text-decoration: none;
  color: #666;
}
#app span {
  margin-right: 10px;
}
.com {
  width: 400px;
  height: 400px;
  border: 1px solid red;
}
.router-link-active {
  color: red;
}
</style>
